// -----------------------------------------------------------
// Game Framework
// Copyright © 2024-2024 deadcycle. All rights reserved.
// Homepage: https://deadcycle.gitee.io
// Feedback: deadcycle@163.com
// -----------------------------------------------------------

using UnityEditor;
using UnityEditor.UI;

using UnityEngine;

namespace UIWidget.Editor
{
    [CustomEditor(typeof(ScrollRectBase))]
    public class ScrollRectBaseInspector : ScrollRectEditor
    {
        private SerializedProperty m_LayoutType;
        private SerializedProperty m_AutoDisableScrolling;

        protected override void OnEnable()
        {
            base.OnEnable();

            m_LayoutType = serializedObject.FindProperty("m_LayoutType");
            m_AutoDisableScrolling = serializedObject.FindProperty("m_AutoDisableScrolling");
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
            {
                using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
                {
                    GUILayout.Label("<b>滚动视图额外配置</b>", GUIStyleHelper.Caption);
                }

                DrawAdditionalConfig();
            }

            EditorGUILayout.Space(5);

            using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
            {
                using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
                {
                    GUILayout.Label("<b>滚动视图基础配置</b>", GUIStyleHelper.Caption);
                }

                base.OnInspectorGUI();
            }
        }

        private void DrawAdditionalConfig()
        {
            m_LayoutType.intValue = (int)(ScrollRectBase.LayoutType)EditorGUILayout.EnumPopup(
                "单元格布局方式",
                (ScrollRectBase.LayoutType)m_LayoutType.intValue);

            EditorGUILayout.PropertyField(m_AutoDisableScrolling,
                new GUIContent("未填满视口时, 自动禁止滚动"), false);

            serializedObject.ApplyModifiedProperties();
        }
    }
}